import java.util.Scanner;
import java.net.*;
import java.io.*;

public class htmlSource {
    // images

	// The path of the folder that you want to save the images to
	private static final String folderPath = "D:\\Toni-TY\\Java\\SoftAcad\\lection 2\\homework2\\Images";

	public static void main(String[] args) throws Exception {
		DownloadImages allImages;

		PrintWriter out;
		BufferedReader in;
		Scanner sc = new Scanner(System.in);
		String URL = "";
		int i = 1;

		do {
			URL = sc.next();
			if (URL.equalsIgnoreCase("0")) {
				break;
			} else {
				out = new PrintWriter("URL" + i + ".txt");
				String inputLine;
				URL oracle = new URL(URL);
				in = new BufferedReader(new InputStreamReader(
						oracle.openStream()));
				// getAllImgFromURL(URL);
				allImages = new DownloadImages(URL);
				allImages.getImagesFromURL();

				i++;
				while ((inputLine = in.readLine()) != null) {
					System.out.println(inputLine);
					out.println(inputLine);
				}
			}
				out.close();
				in.close();
		} while (true);
		sc.close();
	}

}
